package br.ufc.ck0017.temp;

import java.util.HashMap;
import java.util.Map;

public class Label {
    private String name;
    private static int counter;
    private static Map<String, Label> labelPool = new HashMap<>();

    public Label(String name) {
        this.name = name + "_" + counter++;
        labelPool.put(name, this);
    }

    public Label() {
        this.name = "l" + "_" + counter++;
        labelPool.put(name, this);
    }

    @Override
    public String toString() {
        return name;
    }

    public static Label get(String name) {
        if (!labelPool.containsKey(name)) {
            labelPool.put(name, new Label(name));
        }

        return labelPool.get(name);
    }
}
